<!--
 * @FileDescription 雨刮系统
 * @Author lz
 * @Date 20230801 16:24:39
 * @LastEditors lz
 * @LastEditTime 20230801 16:24:39
-->
<template>
    <div class="wis_wp">
        <Hdr></Hdr>
        <img src="/images/Benz600/ic_back.png" class="return_ico" @click="ret">
        <div class="ActionBar">
            <div class="fb_l" @click="VLQR"></div>
            <div class="fb_r" @click="OPQR"></div>

            <div class="LightList LL1"
                :class="statComponen.Default.StatusConfigs.value.get(ObjectControllerCode.Default.MsgCodesList.APPEARENCE_UI_WIPER_FRONT_CLSOE) == 'Selected' ? 'L1_Selected' : ' '"
                @click="highBeam"></div>
            <div class="LightList LL2"
                :class="statComponen.Default.StatusConfigs.value.get(ObjectControllerCode.Default.MsgCodesList.APPEARENCE_UI_WIPER_FRONT_INTERVAL) == 'Selected' ? 'L2_Selected' : ' '"
                @click="LowBeam"></div>
            <div class="LightList LL3"
                :class="statComponen.Default.StatusConfigs.value.get(ObjectControllerCode.Default.MsgCodesList.APPEARENCE_UI_WIPER_FRONT_ONCE) == 'Selected' ? 'L3_Selected' : ' '"
                @mousedown="ArrowClick" @mouseup="ArrowRelease"></div>
            <div class="LightList LL4"
                :class="statComponen.Default.StatusConfigs.value.get(ObjectControllerCode.Default.MsgCodesList.APPEARENCE_UI_WIPER_FRONT_LOW) == 'Selected' ? 'L4_Selected' : ' '"
                @click="LEFT"></div>
            <div class="LightList LL5"
                :class="statComponen.Default.StatusConfigs.value.get(ObjectControllerCode.Default.MsgCodesList.APPEARENCE_UI_WIPER_FRONT_HIGHT) == 'Selected' ? 'L5_Selected' : ' '"
                @click="RightTurn"></div>

            <!-- 文本 -->
            <div class="buttonText t1">
                OFF
            </div>
            <div class="buttonText t2">
                INT
            </div>
            <div class="buttonText t3">
                1X
            </div>
            <div class="buttonText t4">
                LOW
            </div>
            <div class="buttonText t5">
                HIGH
            </div>
        </div>
        <VideoList v-if="HomeContent.Default.VideoList.value"></VideoList>
    </div>
    <QRCodeMask v-if="HomeContent.Default.QRType.value"></QRCodeMask>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import Hdr from '../Head/index.vue'
import VideoList from '../VideoList/index.vue'
import { onMounted, ref, nextTick, reactive } from 'vue';
import ObjectControllerCode from '../ObjectControllerCode';
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import WebSocketComponent from '@runtime/module/WebSocket/WebSocketComponent';
import QRCodeMask from '../QRCodeMask/index.vue'
import MessageCode from '../MessageCode';
import statComponen from '../StateCode';
import OrbitCameraComponent from '../OrbitCameraComponent';
import HomeContent from '../HomeContent';
import GameObjectComponent from '@runtime/UnityEngineBridge/GameObjectComponent';
const router = useRouter()
const state = reactive({
    current: 0,
});
function OPQR() {
    HomeContent.Default.QRType.value = true
}
function VLQR() {
    HomeContent.Default.ModuleType.value = 4
    HomeContent.Default.VideoList.value = true
}
async function ret() {
    HomeContent.Default.engine.value = false
    HomeContent.Default.lamplight.value = false
    HomeContent.Default.bigBox.value = true
    WebSocketComponent.Default.PostMessage(new ClientMessage.DiagnosisAdapterMessage(MessageCode.Default.MsgCodesList.SYSTEM_RESET))
    //隐藏模型
    await GameObjectComponent.Default.ShowHideAsync(HomeContent.Default.ModelID.value[0],false);
    await GameObjectComponent.Default.HideAsync(HomeContent.Default.ModelID.value[2]);
    //重置
    await WebSocketComponent.Default.PostMessageAsync(new ClientMessage.DiagnosisAdapterRequest(MessageCode.Default.MsgCodesList.SYSTEM_RESET))
    HomeContent.Default.VideoList.value = false

    router.push('/')
}
function highBeam() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_CLSOE, Content: '' }
    MessageMethod(newArr)
}
function LowBeam() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_INTERVAL, Content: '' }
    MessageMethod(newArr)
}
function ArrowClick() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_ONCE, Content: 'Press' }
    MessageMethod(newArr)
}
function ArrowRelease() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_ONCE, Content: 'Release' }
    MessageMethod(newArr)
}
function LEFT() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_LOW, Content: '' }
    MessageMethod(newArr)
}
function RightTurn() {
    let newArr = { Id: ObjectControllerCode.Default.MsgCodesList.WIPER_FRONT_HIGHT, Content: '' }
    MessageMethod(newArr)
}
function MessageMethod(Arr: any) {
    WebSocketComponent.Default.PostMessage(new ClientMessage.DiagnosisAdapterMessage(MessageCode.Default.MsgCodesList.DISASSEMBLY_OBJECT_VEHICLE_CONTROLLER, JSON.stringify(Arr)))
}
onMounted(async () => {
    let newArr: any = await WebSocketComponent.Default.PostMessageAsync(new ClientMessage.DiagnosisAdapterRequest(MessageCode.Default.MsgCodesList.VIEW_DATA_CONFIG, `4`))
    console.log(JSON.parse(newArr.Content).Result);
    let ValData = JSON.parse(newArr.Content).Result
    await OrbitCameraComponent.Default.UpdateV2Async(ValData.TargetContainer, ValData.Horizontal, ValData.Vertical, ValData.Distance, ValData.MinDistance, ValData.MaxDistance, ValData.VerticalAngleMax, ValData.VerticalAngleMin, 1, 1, 1,ValData.HorizontalAngleMax,ValData.HorizontalAngleMin);
})
</script>

<style scoped>
.wis_wp {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    position: relative;
    color: #fff;
    background: transparent;
    /* background: #000; */
}

.return_ico {
    width: 50px;
    position: absolute;
    left: 10px;
    top: 10px;
}

.ActionBar {
    width: 1091px;
    height: 181px;
    background-image: url('/images/Benz600/control_window_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    position: absolute;
    bottom: 34px;
    left: 435px;
}

.fb_l {
    width: 89px;
    height: 97px;
    background-image: url('/images/Benz600/btn_play.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    position: absolute;
    left: 24px;
    top: 35px;
}

.fb_l:hover {
    transform: scale(1.05);
    transition: all 0.1s linear;
}

.fb_r {
    width: 119px;
    height: 132px;
    background-image: url('/images/Benz600/btn_QRcode.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    position: absolute;
    top: 17px;
    right: 34px;
}

.fb_r:hover {
    transform: scale(1.05);
    transition: all 0.1s linear;
}

.LightList {
    width: 81px;
    height: 81px;
    position: absolute;
    left: 225px;
    top: 17px;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.LL1 {
    background-image: url('/images/Benz600/ic_off_normal.png');
}

.LL1:hover {
    background-image: url('/images/Benz600/ic_off_active.png');
    transform: scale(1.2);
    transition: all 0.1s linear;
}

.L1_Selected {
    background-image: url('/images/Benz600/ic_off_active.png');
    transform: scale(1.2);
}

.LL2 {
    background-image: url('/images/Benz600/ic_int_normal.png');
    left: 355px;
}

.LL2:hover {
    background-image: url('/images/Benz600/ic_int_active.png');
    transform: scale(1.2);
    transition: all 0.1s linear;
}

.L2_Selected {
    background-image: url('/images/Benz600/ic_int_active.png');
    transform: scale(1.2);
}

.LL3 {
    background-image: url('/images/Benz600/ic_1X_normal.png');
    left: 484px;
}

.LL3:hover {
    background-image: url('/images/Benz600/ic_1X_active.png');
    transform: scale(1.2);
    transition: all 0.1s linear;
}

.L3_Selected {
    background-image: url('/images/Benz600/ic_1X_active.png');
    transform: scale(1.2);
}

.LL4 {
    background-image: url('/images/Benz600/ic_low_normal.png');
    left: 614px;
}

.LL4:hover {
    background-image: url('/images/Benz600/ic_low_active.png');
    transform: scale(1.2);
    transition: all 0.1s linear;
}

.L4_Selected {
    background-image: url('/images/Benz600/ic_low_active.png');
    transform: scale(1.2);
}

.LL5 {
    background-image: url('/images/Benz600/ic_high_normal.png');
    left: 744px;
}

.LL5:hover {
    background-image: url('/images/Benz600/ic_high_active.png');
    transform: scale(1.2);
    transition: all 0.1s linear;
}

.L5_Selected {
    background-image: url('/images/Benz600/ic_high_active.png');
    transform: scale(1.2);
}

.buttonText {
    font-size: 14px;
    font-weight: 500;
    color: #137AA3;
    position: absolute;
}

.t1 {
    left: 252px;
    bottom: 55px;
}

.t2 {
    left: 384px;
    bottom: 55px;
}

.t3 {
    left: 516px;
    bottom: 55px;
}

.t4 {
    left: 640px;
    bottom: 55px;
}

.t5 {
    left: 768px;
    bottom: 55px;
}
</style>